package framework.detectors;

import framework.IWildPointDetector;

/**
 *
 * Implementation of Detector interface to identify lists of values in which all
 * of them exceed the corresponding maximum
 */
public class ExceedDetector implements IWildPointDetector {


    /**
     * The array of maximum values against which each value in the array of measurements
     * received are compared.
     * Correspondence is determined by position in the array.
     */
    private double[] max;


    /**
     * @param max The list of values to initialize the 'maximum values' array
     */
    public ExceedDetector(double[] max) {
        this.max = max;
    }

    /**
     *
     * @param measures Array of measurements to be analyzed
     * @return True if all of the measurements exceeds the correspondind maximum, false otherwise
     */
    public boolean detect(long[] measures) {
        for (int i = 0; i < measures.length; i++) {
            if (this.max[i] >= Double.longBitsToDouble(measures[i])) {
                return false;
            }
        }

        return true;
    }
}
